home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / DDJ0192.ARJ / REBOOT.C < prev    next >
C/C++ Source or Header  |  1991-09-04  |  2KB  |  78 lines

  1. /****************************************************************
  2.  *                                                              *
  3.  * REBOOT.C - Disable ^ALT-DEL for CodeBuilder programs         *
  4.  * Al Williams -- August 1991                                   *
  5.  *                                                              *
  6.  ****************************************************************/
  7. #include <stdio.h>
  8. #include <i32.h>
  9. #include <stk.h>
  10. #include <dos.h>
  11. #include <conio.h>
  12.  
  13. /* When running DOS we replace the keyboard interrupt
  14.    (INT 9) */
  15.  
  16. /* old INT 9 handler */
  17. static void (*oldint9)();
  18.  
  19. #pragma interrupt(ourint9)
  20.  
  21. /* replacement interrupt handler */
  22. static void ourint9()
  23.   {
  24.   int code,temp;
  25. /* pointer to CodeBuilder stack frames */
  26.   _XSTACK *frame=_get_stk_frame();
  27. /* pointer to BIOS shift status byte */
  28.   unsigned char *shift_status=(unsigned char *)0x417;
  29. /* read keyboard */
  30.   code=inp(0x60);
  31.  
  32. /* DEL is scan code 0x53 -- if *shift_status&0xc==0xc then shift
  33.    and Alt are down */
  34.   if (code!=0x53||(*shift_status&0xc)!=0xc) _chain_intr(oldint9);
  35. /* will not allow ^ALT-DEL */
  36. /* consume key from keyboard */
  37.   temp=inp(0x61);
  38.   outp(0x61,temp|0x80);
  39.   outp(0x61,temp);
  40.   outp(0x20,0x20);
  41. /* Tell CodeBuilder not to reissue interrupt */
  42.   frame->opts=_STK_NOINT;
  43.   return;
  44.   }
  45.  
  46. /* This function locks the page ourint9 is on so it can't be
  47.    swapped out. 4K is the minimum size, and surely ourint9
  48.    isn't that big.... */
  49. static lockint9(int flag)
  50.   {
  51.   static lock=0;
  52.   if (flag!=lock)
  53.     {
  54.     lock=flag;
  55.     if (flag)
  56.       _dpmi_lockregion(ourint9,4096);
  57.     else
  58.       _dpmi_unlockregion(ourint9,4096);
  59.     }
  60.   }
  61.  
  62. /********************** External interfaces ******************/
  63.  
  64. /* Disable ^ALT-DEL */
  65. void noreboot()
  66.   {
  67.   lockint9(1);
  68.   oldint9=_dos_getvect(9);
  69.   _dos_setvect(9,ourint9);
  70.   }
  71.  
  72. /* Enable ^ALT-DEL */
  73. void okreboot()
  74.   {
  75.   lockint9(0);
  76.   _dos_setvect(9,oldint9);
  77.   }
  78.